home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / mx / core / ExternalContent.as next >
Encoding:
Text File  |  2007-09-28  |  5.2 KB  |  160 lines

  1. class mx.core.ExternalContent
  2. {
  3.    var createObject;
  4.    var numChildren;
  5.    var prepList;
  6.    var doLater;
  7.    var loadList;
  8.    var dispatchEvent;
  9.    var loadedList;
  10.    var childLoaded;
  11.    static var classConstructed = mx.core.ExternalContent.classConstruct();
  12.    static var ViewDependency = mx.core.View;
  13.    function ExternalContent()
  14.    {
  15.    }
  16.    function loadExternal(url, placeholderClassName, instanceName, depth, initProps)
  17.    {
  18.       var _loc2_ = undefined;
  19.       _loc2_ = this.createObject(placeholderClassName,instanceName,depth,initProps);
  20.       this[mx.core.View.childNameBase + this.numChildren] = _loc2_;
  21.       if(this.prepList == undefined)
  22.       {
  23.          this.prepList = new Object();
  24.       }
  25.       this.prepList[instanceName] = {obj:_loc2_,url:url,complete:false,initProps:initProps};
  26.       this.prepareToLoadMovie(_loc2_);
  27.       return _loc2_;
  28.    }
  29.    function prepareToLoadMovie(obj)
  30.    {
  31.       obj.unloadMovie();
  32.       this.doLater(this,"waitForUnload");
  33.    }
  34.    function waitForUnload()
  35.    {
  36.       var _loc3_ = undefined;
  37.       for(_loc3_ in this.prepList)
  38.       {
  39.          var _loc2_ = this.prepList[_loc3_];
  40.          if(_loc2_.obj.getBytesTotal() == 0)
  41.          {
  42.             if(this.loadList == undefined)
  43.             {
  44.                this.loadList = new Object();
  45.             }
  46.             this.loadList[_loc3_] = _loc2_;
  47.             _loc2_.obj.loadMovie(_loc2_.url);
  48.             delete this.prepList[_loc3_];
  49.             this.doLater(this,"checkLoadProgress");
  50.          }
  51.          else
  52.          {
  53.             this.doLater(this,"waitForUnload");
  54.          }
  55.       }
  56.    }
  57.    function checkLoadProgress()
  58.    {
  59.       var _loc8_ = false;
  60.       var _loc3_ = undefined;
  61.       for(_loc3_ in this.loadList)
  62.       {
  63.          var _loc2_ = this.loadList[_loc3_];
  64.          _loc2_.loaded = _loc2_.obj.getBytesLoaded();
  65.          _loc2_.total = _loc2_.obj.getBytesTotal();
  66.          if(_loc2_.total > 0)
  67.          {
  68.             _loc2_.obj._visible = false;
  69.             this.dispatchEvent({type:"progress",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  70.             if(_loc2_.loaded == _loc2_.total)
  71.             {
  72.                if(this.loadedList == undefined)
  73.                {
  74.                   this.loadedList = new Object();
  75.                }
  76.                this.loadedList[_loc3_] = _loc2_;
  77.                delete this.loadList[_loc3_];
  78.                this.doLater(this,"contentLoaded");
  79.             }
  80.          }
  81.          else if(_loc2_.total == -1)
  82.          {
  83.             if(_loc2_.failedOnce != undefined)
  84.             {
  85.                _loc2_.failedOnce = _loc2_.failedOnce + 1;
  86.                if(_loc2_.failedOnce > 3)
  87.                {
  88.                   this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  89.                   delete this.loadList[_loc3_];
  90.                   false;
  91.                }
  92.             }
  93.             else
  94.             {
  95.                _loc2_.failedOnce = 0;
  96.             }
  97.          }
  98.          _loc8_ = true;
  99.       }
  100.       if(_loc8_)
  101.       {
  102.          this.doLater(this,"checkLoadProgress");
  103.       }
  104.    }
  105.    function contentLoaded()
  106.    {
  107.       var _loc4_ = undefined;
  108.       for(_loc4_ in this.loadedList)
  109.       {
  110.          var _loc2_ = this.loadedList[_loc4_];
  111.          _loc2_.obj._visible = true;
  112.          _loc2_.obj._complete = true;
  113.          var _loc3_ = undefined;
  114.          for(_loc3_ in _loc2_.initProps)
  115.          {
  116.             _loc2_.obj[_loc3_] = _loc2_.initProps[_loc3_];
  117.          }
  118.          this.childLoaded(_loc2_.obj);
  119.          this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  120.          delete this.loadedList[_loc4_];
  121.          false;
  122.       }
  123.    }
  124.    function convertToUIObject(obj)
  125.    {
  126.       if(obj.setSize == undefined)
  127.       {
  128.          var _loc2_ = mx.core.UIObject.prototype;
  129.          obj.addProperty("width",_loc2_.__get__width,null);
  130.          obj.addProperty("height",_loc2_.__get__height,null);
  131.          obj.addProperty("left",_loc2_.__get__left,null);
  132.          obj.addProperty("x",_loc2_.__get__x,null);
  133.          obj.addProperty("top",_loc2_.__get__top,null);
  134.          obj.addProperty("y",_loc2_.__get__y,null);
  135.          obj.addProperty("right",_loc2_.__get__right,null);
  136.          obj.addProperty("bottom",_loc2_.__get__bottom,null);
  137.          obj.addProperty("visible",_loc2_.__get__visible,_loc2_.__set__visible);
  138.          obj.move = mx.core.UIObject.prototype.move;
  139.          obj.setSize = mx.core.UIObject.prototype.setSize;
  140.          obj.size = mx.core.UIObject.prototype.size;
  141.          mx.events.UIEventDispatcher.initialize(obj);
  142.       }
  143.    }
  144.    static function enableExternalContent()
  145.    {
  146.    }
  147.    static function classConstruct()
  148.    {
  149.       var _loc1_ = mx.core.View.prototype;
  150.       var _loc2_ = mx.core.ExternalContent.prototype;
  151.       _loc1_.loadExternal = _loc2_.loadExternal;
  152.       _loc1_.prepareToLoadMovie = _loc2_.prepareToLoadMovie;
  153.       _loc1_.waitForUnload = _loc2_.waitForUnload;
  154.       _loc1_.checkLoadProgress = _loc2_.checkLoadProgress;
  155.       _loc1_.contentLoaded = _loc2_.contentLoaded;
  156.       _loc1_.convertToUIObject = _loc2_.convertToUIObject;
  157.       return true;
  158.    }
  159. }
  160.